Lab 21

  1. Write a complete C++ program that does the following: Sample run of program>
    Enter five numbers: 1 2 3 4 5 Shifted array: 5 1 2 3 4
  2. Write a complete C++ program that has two integer arrays called input and output that each have capacity 10. Fill the input array with random numbers between 1 and 9. Print the contents of the array to the monitor. The program then reads each entry of the input array and sets the entry of the output array for that same index to 3 if the integer at that index is divisible by 3, and 0 if the integer at that index is not divisible by 3.
  3. Sample run of program:
    Input array values: 6 4 6 3 3 4 8 7 4 8 Output array values: 3 0 3 3 3 0 0 0 0 0
  4. Write a complete C++ program that does the following:
  5. Sample run of program:
    8 0 -10 9 4 -7 -8 5 9 -6 -7 10 -5 -9 9 Percentage of negative entries: 46.6667%
  6. Write a complete C++ program that does the following: Sample run of program:
    Please enter a five-digit integer: 74829 The odd digits from left to right are 7 9 The even digits from right to left are 2 8 4
  7. Write a complete C++ program that does the following: The following main function uses maxRow:
    int main(){ int x[2][5] = { {-1, -2, 1, -3, 5}, {-5, -6, -4, -7, -8} }; cout << maxRow(x, 2, 5); // prints 0 // because row 0 has two positive entries and row 1 has none return 0; }